package My;

import java.util.ArrayList;
import java.util.List;

public class Demo01 {
    public List<List<Integer>> generate(int numRows){
        List<List<Integer>> result = new ArrayList<>();
        for (int i = 0; i < numRows; i++) {
            List<Integer> row = new ArrayList<>();
            for (int j = 0; j < i+1; j++) {
                if (j ==0 || j==i){
                    row.add(1);
                }else {
                    int current = result.get(i-1).get(j-1) +result.get(i-1).get(j);
                    row.add(current);
                }
            }
            result.add(row);
        }
        return result;
    }

    public static void main(String[] args) {
        Demo01 demo01 = new Demo01();
        List<List<Integer>> result = demo01.generate(5);
        System.out.println(result);
    }
}
